package cn.rongdao.jrkabao.ui.IdentificationVerificate.uicomponent;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import cn.rongdao.jrkabao.R;
import cn.rongdao.jrkabao.ui.loan.uicomponent.CommonHeaderUIComponent;

/**
 * Created by jiangyongxing on 2017/9/19.
 * 描述：
 */

public class ValidationItemUIComponent extends RelativeLayout {

    private TextView mTvSubmit;
    private View mShadow;
    private TextView mTvTitle;
    private ValidationItemCenterViewUIComponent mValidationItemCenterViewUIComponent;
    private CommonHeaderUIComponent mCommonHeaderUIComponent;

    public ValidationItemUIComponent(Context context) {
        super(context);
    }

    public ValidationItemUIComponent(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public ValidationItemUIComponent(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        mTvSubmit = (TextView) findViewById(R.id.lviu_tv_submit);
        mTvTitle = (TextView) findViewById(R.id.lch_tv_title);
        mShadow = findViewById(R.id.lviu_shadow);
        mCommonHeaderUIComponent = (CommonHeaderUIComponent) findViewById(R.id.lviu_header);
        mValidationItemCenterViewUIComponent = (ValidationItemCenterViewUIComponent) findViewById(R.id.lviu_item_center);
        initListener();
    }

    private void initListener() {
        mShadow.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });


    }

    public void setSubmitOnclickListener(OnClickListener listener) {
        mTvSubmit.setOnClickListener(listener);
    }

    public void setContent(int drawable, String title, String desc){
        mValidationItemCenterViewUIComponent.setContent(drawable,title,desc);
    }

    public void setTitle(String title){
        mCommonHeaderUIComponent.setContent(title);
    }

    /**
     * Visiable表示不可用
     *
     * @param visiable
     */
    public void setContentDisable(int visiable) {
        mShadow.setVisibility(visiable);
        mTvSubmit.setBackgroundDrawable(getResources().getDrawable(visiable == View.VISIBLE ? R.drawable.btn_disable_bg : R.drawable.btn_enable_bg));
    }

}
